// 渲染
package core

import (
	"httpadmin/go-attribute/application/constant"
	"net/http"
)

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func (app *Wrap) StringOut(res string) {
	app.Gin.String(http.StatusOK, res)
}

func (app *Wrap) JsonOk(data interface{}) {
	app.JsonOut(constant.ErrOk, "", data)
}

func (app *Wrap) JsonError(err error) {
	app.JsonErrMsg(err.Error())
}

func (app *Wrap) JsonErrMsg(errMsg string) {
	app.JsonOut(constant.ErrToast, errMsg, nil)
}

func (app *Wrap) JsonOut(bizCode int, errMsg string, data interface{}) {
	app.Gin.JSON(http.StatusOK, Response{
		Code: bizCode,
		Msg:  errMsg,
		Data: data,
	})
}
